package com.hirisun.calendar.filter;

import java.util.Calendar;
import java.util.Date;

public class WeakendFilter implements IVocationFilter {
	
	private int[] weakends = {7, 1};

	public void setWeaks(int[] weakends) {
		this.weakends = weakends;
	}

	public boolean isVocation(Date date) {		
		int day = getWeek(date);
		
		for(int i = 0; i < weakends.length; i++){
			if(weakends[i] == day){
				return true;
			}
		}
		
		return false;
	}
	
	private int getWeek(Date date){
		
		Calendar calendar = Calendar.getInstance();
		
		calendar.setTime(date);
		
		int day = calendar.get(Calendar.DAY_OF_WEEK);
		
		return day;
	}

}
